package com.xpec.c4.db.datatransfer.logic;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

//import com.xpec.c4.db.dao.PlayerDAO;
//import com.xpec.c4.db.inactivedao.InactivePlayerDAO;
//import com.xpec.c4.db.inactivemodel.InactivePlayerModel;
//import com.xpec.c4.db.model.BasicPlayerModel;
//import com.xpec.c4.db.model.PlayerModel;
//import com.xpec.c4.db.model.log.ItemChangeType;
//import com.xpec.c4.db.usertype.KitbagToString;
//import com.xpec.c4.db.usertype.WarehouseToString;
//import com.xpec.c4.game.goodsagent.GoodsAgent;
//import com.xpec.c4.game.goodsagent.ModifyGoodsResult;
//import com.xpec.c4.game.kitbag.Kitbag;
/**
 * 移除玩家身上的被包 / 倉庫的東西 , TODO 目前不包含公用倉庫的東西
 * @author Wilson_Wu
 *
 */
public class RemoveGoodsLogic extends BasicTransferLogic{
	private static final Log log = LogFactory.getLog(RemoveGoodsLogic.class);
	@Override
	public int executeLogic(String[] args) {
		log.info("execute RemoveGoodsLogic logic start");
		if(args.length <= 1){
			log.info("RemoveGoodsLogic param error , no goods to remove");
			return -1;
		}
		
//		List<PlayerModel> playerModel = PlayerDAO.loadAllPlayerModelsByGuid();
//		List<InactivePlayerModel> playerModel2 = InactivePlayerDAO.loadAllPlayerModels();
//		List<PlayerModel> modifyList1 = null;
//		List<InactivePlayerModel> modifyList2 = null;
//		if(playerModel != null){
//			 modifyList1 = procRemoveGoods(playerModel , args);
//		}
//		
//		if(playerModel2 != null){
//			modifyList2 = procRemoveGoods(playerModel2 , args);
//		}
//		if(modifyList1.size() > 0)
//			PlayerDAO.saveOrUpdatePlayerModels(modifyList1);
//		if(modifyList2.size() > 0)
//			InactivePlayerDAO.saveOrUpdatePlayerModels(modifyList2);
//		log.info("execute RemoveGoodsLogic logic end");
		return 0;
	}
	
//	private <T extends BasicPlayerModel> List<T> procRemoveGoods(List<T> list,  String[] args){
//		List<T> returnList = new ArrayList<T>();
//		
//		for(T p  : list){
//			BasicPlayerModel player = (BasicPlayerModel) p;
//			if(player == null) continue;
//			boolean dirty = false;
//			
//			for(int x = 1 ; x < args.length; x++){
//				String target = args[x];
//				if(player.getKitbag() != null){
//					ModifyGoodsResult result = player.getKitbag().removeGoodsByKindID(target, Integer.MAX_VALUE, GoodsAgent.BINDCONDITION_NOCARE, ItemChangeType.SYSTEM_RESUME);
//					if(result.isSucceed())
//						dirty = true;
//				}
//				if(player.getWarehouse() != null){
//					ModifyGoodsResult result = player.getWarehouse().removeGoodsByKindID(target, Integer.MAX_VALUE, GoodsAgent.BINDCONDITION_NOCARE, ItemChangeType.SYSTEM_RESUME);
//					if(result.isSucceed())
//						dirty = true;
//				}
//				if(player.getKitbagExtend() != null){
//					ModifyGoodsResult result = player.getKitbagExtend().removeGoodsByKindID(target, Integer.MAX_VALUE, GoodsAgent.BINDCONDITION_NOCARE, ItemChangeType.SYSTEM_RESUME);
//					if(result.isSucceed())
//						dirty = true;
//				}
//				if(player.getWarehouseExtend() != null){
//					ModifyGoodsResult result = player.getWarehouseExtend().removeGoodsByKindID(target, Integer.MAX_VALUE, GoodsAgent.BINDCONDITION_NOCARE, ItemChangeType.SYSTEM_RESUME);
//					if(result.isSucceed())
//						dirty = true;
//				}
//			}
//			if(dirty)
//				returnList.add(p);
//		}
//		return returnList;
//	}
	@Override
	public String getName() {
		return "rmGoods";
	}
}
